<template>
  <div class="item product css-slide--snap card">
    <div class="img-wrapper">
      <div @click="openNWin(good.id)">
        <q-img :src="good.image">
        </q-img>
      </div>
    </div>

    <div class="detail spacing--xlarge product-item__text card__text">
      <a href="javascript:;" class="title"><div class="title-inner"><span>{{good.name}}</span></div></a>
    </div>


  </div>
</template>

<script setup lang='ts'>
import {defineProps, defineEmits, defineExpose} from 'vue'

defineProps({
  src: {
    type: String,
    default: "@/assets/images/cat4.png"
  },
  good:{
    type: Object,
    default: {
      id: 1
    }
  }
})

const openNWin = (good_id) => {
  window.open(`#/pc/category/` + good_id, "_blank");
}

const emit = defineEmits([])

defineExpose({})
</script>

<style scoped lang='less'>
.item {
  background-color: white;
  border-radius: 10px;
  flex: 0 0 calc(50% - 2px); /* 每个元素占据25%的宽度 */
  border: 1px solid #ccc; /* 边框 */
  margin-right: 14px; /* 间隙 */
  //text-align: center;
  //&:nth-child(2){
  //  margin-right: unset;
  //}
  overflow: hidden; /* 防止放大的图片溢出容器 */
  .img-wrapper{
    overflow: hidden;
  }
  .detail{
    padding: 25px;
    .title{
      font-size: 20px;
      font-weight: 800;
      text-align: center;
      .title-inner{
        margin-bottom: -10px;
      }
      span{
        position: relative;
        &::after {
          content: '';
          position: absolute;
          left: 0;
          bottom: 0;
          width: 0;
          height: 1px;
          background-color: #000000; /* 边框颜色 */
          transition: width 0.5s ease; /* 过渡效果 */
        }
        &:hover::after {
          width: 100%; /* 鼠标悬浮时边框宽度为100% */
        }
      }
    }
    .tag-wrapper{
      display: flex; /* 启用 flexbox 布局 */
      flex-wrap: wrap; /* 当容器内没有足够空间时，允许子元素换行 */
      gap: 3px;
      .tag{
        padding: 5px;
        background-color: #c5c5c5;
        border-radius: 4px;
      }
    }
  }
}

.item:last-child {
  margin-right: 0; /* 最后一个元素不需要间隙 */
}


.q-img:hover{
  transform: scale(1.05); /* 当鼠标悬浮时放大图片 5% */
  transition: transform 0.3s ease-in-out; /* 添加平滑的过渡效果 */
}

.product{
  display: flex;
  flex-direction: column;
  overflow: visible;
}
.css-slide--snap{
  scroll-snap-align: start;
}
.card{
  --border-width-cards: 1px;
  --border-radius-cards: 10px;
  --border-width-buttons: 1px;
  --border-radius-buttons: 30px;
  --border-width-forms: 1px;
  --border-radius-forms: 5px;
  --shadow-x-cards: 0px;
  --shadow-y-cards: 0px;
  --shadow-blur-cards: 0px;
  border: solid var(--border-width-cards) #e1e1e1;
  border-radius: var(--border-radius-cards);
  overflow: hidden;
  background-color: #ffffff;
  position: relative;
  color: #1d1d1d;
  box-shadow: var(--shadow-x-cards) var(--shadow-y-cards) var(--shadow-blur-cards) rgba(0,0,0,0);
  margin-bottom: calc(var(--shadow-y-cards) + var(--shadow-blur-cards));
  margin-inline-end: calc(var(--shadow-x-cards) + var(--shadow-blur-cards));
}
</style>